local Action_PrepareStage = 
{
    TotalTime = 0;            -- 准备阶段时长
}

--执行了
function Action_PrepareStage:Execute()
    print(string.format("Action_PrepareStage:Execute TotalTime[%d]", self.TotalTime))

    self.bEnableActionTick = true
    -- 进入准备阶段的时间
    self.EnterStatgeTime = GameplayStatics.GetRealTimeSeconds(self)
    -- 更新信息面板间隔
    self.Timer = GameplayStatics.GetRealTimeSeconds(self)
	-- 设置游戏状态为准备中
	UGCGameSystem.GameState.CurrentGamestate = EGameStatus.WaitReady;
	return true
end

function Action_PrepareStage:Update(DeltaTime)
    print("Action_PrepareStage:Update");
    -- 计算剩余时间
    local CurrentRealTime = GameplayStatics.GetRealTimeSeconds(self)
    local RemainTime = self.TotalTime - (CurrentRealTime - self.EnterStatgeTime)
    --UnrealNetwork.CallUnrealRPC_Multicast(UGCGameSystem.GameState, "Multicast_PlayerPanel", UGCGameSystem.GameState.PlayerInfos);
    -- 每隔5秒更新一次信息面板，更新玩家加入后的数据
    local TempCount = CurrentRealTime - self.Timer;
    if TempCount > 5 then
        --玩家数据同步到客户端
        UnrealNetwork.CallUnrealRPC_Multicast(UGCGameSystem.GameState, "Multicast_PlayerPanel", UGCGameSystem.GameState.PlayerInfos);
        self.Timer = CurrentRealTime;
    end
    --UI显示
    UGCGameSystem.GameState.PrepareStageRemainTime = RemainTime
    if RemainTime <= 0 then
        self:EndPrepareStage();
	end
end

function Action_PrepareStage:EndPrepareStage()
    print(string.format("Action_PrepareStage:EndPrepareStage"))
  
    self.bEnableActionTick = false;
    -- 记录游戏开始时间
    UGCGameSystem.GameState.GameStartTime = GameplayStatics.GetRealTimeSeconds(self)
    UGCGameSystem.GameState.RoundNum = 0
    -- 设置游戏状态为游戏中
    UGCGameSystem.GameState.CurrentGamestate = EGameStatus.Gaming;
    --再次更新玩家面板，UI显示 玩家信息面板、卡牌
    UnrealNetwork.CallUnrealRPC_Multicast(UGCGameSystem.GameState, "Multicast_PlayerPanel", UGCGameSystem.GameState.PlayerInfos);
    --游戏开始标志
    UnrealNetwork.CallUnrealRPC_Multicast(UGCGameSystem.GameState, "Multicast_ShowStartTips");
    LuaQuickFireEvent("AdjustCard", self)
end

return Action_PrepareStage